package com.xzx.taskqueue;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.CharsetUtil;

import java.nio.charset.StandardCharsets;

/**
 *
 * @author xinzhixuan
 * @version 1.0
 * @date 2025/10/24 16:48
 */
public class ServerHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ByteBuf buf = (ByteBuf) msg;
        System.out.println("服务端收到数据：" + buf.toString(StandardCharsets.UTF_8));
        ctx.writeAndFlush(Unpooled.copiedBuffer("hello 客户端".getBytes(StandardCharsets.UTF_8)));
    }
}
